/**
 * 数据字典
 */
const mongoose = require('mongoose')
const shortid = require('shortid')
const moment = require('moment')
const DataManage = require('../datamanageType/models.js')
const Schema = mongoose.Schema

const DataManageSchema = new Schema({
  // 数据库中存储ID
  _id: {
    type: String,
    default: shortid.generate
  },
  // 分类
  datatype:{
    type: String,
    ref: 'DataManage'
  },
  datacode:String,// 字典编码
  dataname: String,    // 字典名称
  description: String,    // 字典描述
  // 是否激活
  enable: {
    type: Boolean,
    default: true
  },
  create_time: {
    type: Date,
    default: Date.now
  }
})

DataManageSchema.path('create_time').get(function (v) {
  return moment(v).utc().utcOffset(-8).format("YYYY-MM-DD")
})

module.exports = mongoose.model('DataManageList', DataManageSchema)